package com.cros.pruebas;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Expresion {
	
	public static void main(String argv[]){
		String cadena;
		StringBuilder br = new StringBuilder();
		
		File f = new File("C:\\Users\\Jesus\\Documents\\probando.txt");
		try {
			FileReader fr = new FileReader(f);
			BufferedReader bff = new BufferedReader(fr);
			
			while((cadena=bff.readLine())!=null){
				br.append(cadena).append("\\n");
			}
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		HashMap<String,String> mapa = getMethods(br.toString());
		
		Iterator it = mapa.entrySet().iterator();
		while (it.hasNext()) {
		Map.Entry e = (Map.Entry)it.next();
		System.out.println(e.getKey() + " " + e.getValue());
		}

	
	
		
	}
	
	public static HashMap<String,String> getMethods(String str){
		String pattern="[a-zA-Z_]+[0-9]*\\.get[A-Z](\\w)*\\(\\)";
		Pattern p = Pattern.compile(pattern);
		Matcher m = p.matcher(str);
		HashMap<String,String> map = new HashMap<String,String>();
		while(m.find()) {
			map.put(m.group(),m.group());
		}
		return map;
		
	}

}
